import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;


public class UI implements ActionListener{
	private JFrame frame;
	private JPanel panel;
	private JButton Multiplayer;
	private JButton Solo;
	private ImageIcon iiBackGround;
	private JLabel labelMonopoly;
	private Multiplayer Multi;
	
	public UI() {
		this.initComponents();
	}
	
	public void initComponents(){
		frame = new JFrame("Monopoly");
		panel = new JPanel();
		Solo = new JButton();
		iiBackGround = new ImageIcon("images/startui.jpg");
		ImageIcon start = new ImageIcon("images/button/solo.png");
		ImageIcon multiplayer = new ImageIcon("images/button/multi player.png");
		Multiplayer = new JButton();
		labelMonopoly = new JLabel(iiBackGround);
		panel.setLayout(null);
		Solo.setBounds(140, 150, 65, 30);
		Multiplayer.setBounds(95, 190, 150, 30);
		labelMonopoly.setBounds(0,0,350,350);
		panel.add(Solo);
		Solo.setBorder(null);
		Solo.setBorderPainted(false);
		Solo.setContentAreaFilled(false);
		Solo.setOpaque(false);
		Solo.setIcon(start);
		Solo.setRolloverIcon(new ImageIcon("images/button/solo1.png"));
		panel.add(Multiplayer);
		Multiplayer.setIcon(multiplayer);
		Multiplayer.setRolloverIcon(new ImageIcon("images/button/multi player1.png"));
		Multiplayer.setBorder(null);
		Multiplayer.setBorderPainted(false);
		Multiplayer.setContentAreaFilled(false);
		Multiplayer.setOpaque(false);
		Multiplayer.addActionListener(this);
		Multiplayer.setActionCommand("Multiplayer");
		Solo.addActionListener(this);
		Solo.setActionCommand("Solo");
		panel.add(labelMonopoly);
	}
	
	public void createAndShowGUI(){
		frame.add(panel);
		frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		frame.setBounds(350, 200, 350, 350);
		frame.setVisible(true);
	}
	
	public static void main(String[] args) {
		UI test = new UI();
		test.createAndShowGUI();
	}
	
	public void actionPerformed(ActionEvent e) {
		Multi = new Multiplayer();
		if("Multiplayer".equals(e.getActionCommand())){
			Multi.createAndShowGUI(true);
			frame.setVisible(false);
		}
		if("Solo".equals(e.getActionCommand())){
			Multi.createAndShowGUI(false);
			frame.setVisible(false);
		}
	}
}